﻿
Ext.namespace('FantastPlatform', 'FantastPlatform.UI');
FantastPlatform.UI.AreaHanppenCase = function (config) {

    Ext.apply(this, config);

    var fileStore = new Ext.data.Store({
        proxy: new Ext.data.HttpProxy({
            url: '../Service/AreaHanppenCaseService.aspx?Action=Search'

        }),
        reader: new Ext.data.JsonReader({
            root: 'topics',
            totalProperty: 'totalCount',
            id: 'Id',
            fields: ['Station', 'ResponsibilityArea', 'Street', 'CaseCount']
        }),
        remoteStore: true
    });

    this.store = fileStore;

    var paperBar = new FantastPlatform.Common.PapeToolBar({
        store: fileStore,
        noSort: true,
        defaultNum: 21
    });
    this.paperBar = paperBar;
    this.bbar = paperBar;
    this.pageNumber = paperBar.pageSize;

    var nm = new Ext.grid.RowNumberer();
    var sm = new Ext.grid.CheckboxSelectionModel();

    this.columns = [nm, sm, {
        header: '派出所',
        dataIndex: 'Station',
        width: 100,
        sortable: true
    }, {
        header: '责任区',
        dataIndex: 'ResponsibilityArea',
        width: 200,
        sortable: true
    }, {
        header: '街道',
        width: 120,
        dataIndex: 'Street',
        sortable: true
    }, {
        header: '案件数',
        width: 100,
        dataIndex: 'CaseCount'
    }];
    FantastPlatform.UI.AreaHanppenCase.superclass.constructor.call(this, {
        loadMask: { msg: '正在加载数据...' },
        sm: sm
    });
}

Ext.extend(FantastPlatform.UI.AreaHanppenCase, Ext.grid.GridPanel, {
    onRender: function (ct, position) {
        FantastPlatform.UI.AreaHanppenCase.superclass.onRender.call(this, ct, position);
    },
    onSearchClick: function () {
        var id = GUID();
        currtWind = openWind('../AreaCaseSearch.aspx', id, '查询', 560, 370, 'new_tab');
    },

    onSeebyTimeClick: function () {
        var id = GUID();
        currtWind = openWind('../TimeHanppenCase.aspx', id, '按时间段查看案件', 360, 170, 'new_tab');
    },
    //刷新
    onUpdataClick: function () {
        this.store.removeAll();
        this.store.proxy.conn = { method: 'post', url: this.url };
        this.store.load({ params: { start: 0, limit: this.paperBar.getPageNumber(), dir: '', sort: ''} });
    }
});
    
